<template>
  <EditOrViewTable :table-data="tableData" :type="type" :show-selection="false" :setting="setting" :show-btn="false" />
</template>
<script>
import EditOrViewTable from '../../components/editOrViewTable'
export default {
  name: 'FreezeTable',
  components: {
    EditOrViewTable
  },
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    type: {
      type: String,
      default: 'view'
    },
    isFreeze: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      setting: [
        {
          prop: 'isChange',
          label: '是否冻结',
          minWidth: 140,
          editRender: (h, row) => {
            let disabled = false
            if (this.isFreeze) {
              disabled = [1, '1'].includes(row.state)
            } else {
              disabled = ![1, '1'].includes(row.state)
            }
            return h('el-switch', {
              props: {
                value: row.isChange,
                activeValue: 1,
                inactiveValue: 0,
                disabled
              },
              on: {
                input: v => {
                  this.$set(row, 'isChange', v)
                }
              },
              nativeOn: {
                click: e => e.stopPropagation()
              }
            })
          },
          propEnum: {
            domainCode: 'marketing',
            appCode: 'slm',
            dictTypeCode: 'BOOLEANS'
          }
        },
        {
          prop: 'accountCode',
          label: '账号编码',
          minWidth: 120
        },
        {
          prop: 'accountName',
          label: '账号名称',
          minWidth: 120
        },
        {
          prop: 'accountTypeName',
          label: '账号类型',
          minWidth: 120
        },
        {
          prop: 'state',
          label: '当前冻结状态',
          minWidth: 120,
          formatData: v => {
            return [1, '1'].includes(v.state) ? '是' : '否'
          }
        }
      ]
    }
  },
  created() {
    if (!this.isFreeze) {
      const t = this.setting.find(e => e.prop === 'isChange')
      t.label = '是否解冻'
    }
  },
  methods: {
  }
}
</script>
